<!DOCTYPE html>
<html>
<head>
<title>后台管理系统</title>
#@head()
</head>

<body class="gray-bg">
	<div class="wrapper wrapper-content ">
		<div class="col-sm-12">
	        <div class="ibox">
	        	<div class="ibox-title">
					<h5>部门管理</h5>
				</div>
	            <div class="ibox-content">
	                <div class="fixed-table-toolbar">
	                    <div class="columns pull-left">
							#if(shiro.hasPermission("sys:dept:add"))
	                        <button type="button" class="btn  btn-primary" onclick="add(0)">
	                            <i class="fa fa-plus " aria-hidden="true"></i>添加
	                        </button>
							#end
	                    </div>

	                    <!--<div class="columns pull-right">
	                        <button class="btn btn-success" onclick="reLoad()">查询</button>
	                    </div>
	
	                    <div class="columns pull-right col-md-2 nopadding">
	                        <input id="searchName" type="text" class="form-control"
	                               placeholder="">
	                    </div>-->

	                </div>
	                <table id="exampleTable" class="table table-hover table-bordered" data-mobile-responsive="true"></table>
	            </div>
	        </div>
	    </div>
	</div>
</body>
#@footer()

<script type="text/javascript">

function del(id){
	layer.confirm('您确定要删除嘛？',function(){
		$.post('remove?id='+id,'',function(res){
			if(res.code==0){
				layer.msg(res.msg,{time:1000},function(){
					location.reload();
				})
			}
		})
	})
}
function add(parentId){
	openWindow('添加','add?parentId='+parentId)
}

function edit(id){
	openWindow('修改','edit?id='+id)
}

function reLoad() {
	console.log('刷新')
	load();
    $('#exampleTable').bootstrapTreeTable('refresh');
}


var ctx = '';
var prefix = ctx +"./"
$(function() {
	load();
});

var columns = [
	{
		title : '编号',
		field : 'id',
		align : 'center',
		valign : 'center',
		width : '50px',
	},
	{
		field : 'name',
		title : '部门名称',
        valign : 'center',
        align : 'left',
	},
	{
		field : 'typeName',
		title : '类型',
        align : 'center',
        valign : 'center',
        width : '80px',
	},
	{
		field : 'orderNum',
		title : '排序',
        align : 'center',
        valign : 'center',
        width : '80px',
	},
	{
		field : 'delFlag',
		title : '状态',
		align : 'center',
        valign : 'center',
        width : '80px',
		formatter : function(row,index ) {
			if (row.delFlag == 0) {
				return '<span class="label label-danger">禁用</span>';
			} else if (row.delFlag == 1) {
				return '<span class="label label-primary">正常</span>';
			}
		}
	},
	{
		title : '操作',
		align : 'left',
        valign : 'center',
        width : '165px',
		formatter : function(row,index ) {
			var e = '<a class=" '  + '" href="#" mce_href="#" title="编辑" onclick="edit(\''
				+ row.id
				+ '\')"> 编辑 </a> &nbsp;';
			
			var d = '<a class=" '  + '" href="#" title="删除"  mce_href="#" onclick="del(\''
				+ row.id
				+ '\')"> 删除 </a> &nbsp;';

			var a = '<a class=" '  + '" href="#" title="增加下級"  mce_href="#" onclick="add(\''
			+ row.id
			+ '\')"> 增加下级 </a> &nbsp;';
				
			return e + d + a;
		}
	} ];

function load(){
    $('#exampleTable').bootstrapTreeTable({
        id: 'id',
        code: 'id',
        rootCodeValue: 0,
        parentCode: 'parentId',
        expandColumn: '1',// 在哪一列上面显示展开按钮
        striped: true, // 是否各行渐变色
        bordered: true, // 是否显示边框
        expandAll: false, // 是否全部展开
	    url: "dataAjax",
	    queryParams: function(params) {
            return {
                // 传递参数查询参数
                offset: (params.offset / params.limit) + 1,
                limit:   params.limit
            };
        },
	    columns : columns ,
	});
}

</script>
</html>



